﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReportGas.aspx.cs" Inherits="MDH_ReportTTLL" %>

<%@ Register Src="../Interface/header.ascx" TagName="header" TagPrefix="uc1" %>
<%@ Register Src="../Interface/footer.ascx" TagName="footer" TagPrefix="uc2" %>
<%@ Register TagPrefix="hmwebmenu" TagName="MyMenu" Src="~/Interface/menu.ascx"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Bao cao tieu thu xang dau</title>
    <link href="../VNPTStyle.css" type="text/css" rel="stylesheet" />
    <link href="../VNPTStyle.css" rel="stylesheet" type="text/css" />
    <SCRIPT LANGUAGE="JavaScript">
	var imagePath='../Image/';
	
	var ie=document.all;
	var dom=document.getElementById;
	var ns4=document.layers;
	var bShow=false;
	var textCtl;

	function setTimePicker(t) {
		textCtl.value=t;
		closeTimePicker();
	}

	function refreshTimePicker(mode) {
		
		if (mode==0)
			{ 
				suffix="am"; 
			}
		else
			{ 
				suffix="pm"; 
			}

		sHTML = "<table><tr><td><table cellpadding=3 cellspacing=0 bgcolor='#f0f0f0'>";
		for (i=0;i<=11;i++) {

			sHTML+="<tr align=right style='font-family:verdana;font-size:9px;color:#000000;'>";

			if (i==0  && suffix=="pm") {
				hr = 12;
			}
			else {
				hr = i;
			}	

			for (j=0;j<4;j++) {
				sHTML+="<td width=57 style='cursor:hand' onmouseover='this.style.backgroundColor=\"#66CCFF\"' onmouseout='this.style.backgroundColor=\"\"' onclick='setTimePicker(\""+ hr + ":" + padZero(j*15) + " " + suffix + "\")'><a style='text-decoration:none;color:#000000' href='javascript:setTimePicker(\""+ hr + ":" + padZero(j*15) + " " + suffix + "\")'>" + hr + ":"+padZero(j*15) + "<font color=\"#808080\">" + suffix + "</font></a></td>";
			}

			sHTML+="</tr>";
		}
		sHTML += "</table></td></tr></table>";
		document.getElementById("timePickerContent").innerHTML = sHTML;
	}

	if (dom){
		document.write ("<div id='timepicker' style='z-index:+999;position:absolute;visibility:hidden;'><table style='border-width:3px;border-style:solid;border-color:#0033AA' bgcolor='#ffffff' cellpadding=0><tr bgcolor='#0033AA'><td><table cellpadding=0 cellspacing=0 width='100%' background='" + imagePath + "titleback.gif'><tr valign=bottom height=21><td style='font-family:verdana;font-size:11px;color:#ffffff;padding:3px' valign=center><B>&nbsp;&nbsp;Select a Time&nbsp;&nbsp;</B></td><td><img id='iconAM' src='" + imagePath + "am1.gif' onclick='document.getElementById(\"iconAM\").src=\"" + imagePath + "am1.gif\";document.getElementById(\"iconPM\").src=\"" + imagePath + "pm2.gif\";refreshTimePicker(0)' style='cursor:hand'></td><td><img id='iconPM' src='" + imagePath + "pm2.gif' onclick='document.getElementById(\"iconAM\").src=\"" + imagePath + "am2.gif\";document.getElementById(\"iconPM\").src=\"" + imagePath + "pm1.gif\";refreshTimePicker(1)' style='cursor:hand'></td><td align=right valign=center>&nbsp;<img onclick='closeTimePicker()' src='" + imagePath + "close.gif'  STYLE='cursor:hand'>&nbsp;</td></tr></table></td></tr><tr><td colspan=2><span id='timePickerContent'></span></td></tr></table></div>");
		refreshTimePicker(0);
	}

	var crossobj=(dom)?document.getElementById("timepicker").style : ie? document.all.timepicker : document.timepicker;
	var currentCtl

	function selectTime(ctl,ctl2) {
		var leftpos=0
		var toppos=0
		textCtl=ctl2;
		currentCtl = ctl
		currentCtl.src=imagePath + "timepicker2.gif";

		aTag = ctl
		do {
			aTag = aTag.offsetParent;
			leftpos	+= aTag.offsetLeft;
			toppos += aTag.offsetTop;
		} while(aTag.tagName!="BODY");
		crossobj.left =	ctl.offsetLeft	+ leftpos 
		crossobj.top = ctl.offsetTop +	toppos + ctl.offsetHeight +	2 
		crossobj.visibility=(dom||ie)? "visible" : "show"
		hideElement( 'SELECT', document.getElementById("calendar") );
		hideElement( 'APPLET', document.getElementById("calendar") );			
		bShow = true;
	}

	// hides <select> and <applet> objects (for IE only)
	function hideElement( elmID, overDiv ){
		if( ie ){
			for( i = 0; i < document.all.tags( elmID ).length; i++ ){
				obj = document.all.tags( elmID )[i];
				if( !obj || !obj.offsetParent ){
						continue;
				}
				  // Find the element's offsetTop and offsetLeft relative to the BODY tag.
				  objLeft   = obj.offsetLeft;
				  objTop    = obj.offsetTop;
				  objParent = obj.offsetParent;
				  while( objParent.tagName.toUpperCase() != "BODY" )
				  {
					objLeft  += objParent.offsetLeft;
					objTop   += objParent.offsetTop;
					objParent = objParent.offsetParent;
				  }
				  objHeight = obj.offsetHeight;
				  objWidth = obj.offsetWidth;
				  if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
				  else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
				  else if( overDiv.offsetTop >= ( objTop + objHeight + obj.height ));
				  else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
				  else
				  {
					obj.style.visibility = "hidden";
				  }
			}
		}
	}
		 
	//unhides <select> and <applet> objects (for IE only)
	function showElement( elmID ){
		if( ie ){
			for( i = 0; i < document.all.tags( elmID ).length; i++ ){
				obj = document.all.tags( elmID )[i];
				if( !obj || !obj.offsetParent ){
						continue;
				}
				obj.style.visibility = "";
			}
		}
	}

	function closeTimePicker() {
		crossobj.visibility="hidden"
		showElement( 'SELECT' );
		showElement( 'APPLET' );
		currentCtl.src=imagePath + "timepicker.gif"
	}

	document.onkeypress = function hideTimePicker1 () { 
		if (event.keyCode==27){
			if (!bShow){
				closeTimePicker();
			}
		}
	}

	function isDigit(c) {
		
		return ((c=='0')||(c=='1')||(c=='2')||(c=='3')||(c=='4')||(c=='5')||(c=='6')||(c=='7')||(c=='8')||(c=='9'))
	}

	function isNumeric(n) {
		
		num = parseInt(n,10);

		return !isNaN(num);
	}

	function padZero(n) {
		v="";
		if (n<10){ 
			return ('0'+n);
		}
		else
		{
			return n;
		}
	}

	function validateDatePicker(ctl) {

		t=ctl.value.toLowerCase();
		t=t.replace(" ","");
		t=t.replace(".",":");
		t=t.replace("-","");

		if ((isNumeric(t))&&(t.length==4))
		{
			t=t.charAt(0)+t.charAt(1)+":"+t.charAt(2)+t.charAt(3);
		}

		var t=new String(t);
		tl=t.length;

		if (tl==1 ) {
			if (isDigit(t)) {
				ctl.value=t+":00 am";
			}
			else {
				return false;
			}
		}
		else if (tl==2) {
			if (isNumeric(t)) {
				if (parseInt(t,10)<13){
					if (t.charAt(1)!=":") {
						ctl.value= t + ':00 am';
					} 
					else {
						ctl.value= t + '00 am';
					}
				}
				else if (parseInt(t,10)==24) {
					ctl.value= "0:00 am";
				}
				else if (parseInt(t,10)<24) {
					if (t.charAt(1)!=":") {
						ctl.value= (t-12) + ':00 pm';
					} 
					else {
						ctl.value= (t-12) + '00 pm';
					}
				}
				else if (parseInt(t,10)<=60) {
					ctl.value= '0:'+padZero(t)+' am';
				}
				else {
					ctl.value= '1:'+padZero(t%60)+' am';
				}
			}
			else
   		    {
				if ((t.charAt(0)==":")&&(isDigit(t.charAt(1)))) {
					ctl.value = "0:" + padZero(parseInt(t.charAt(1),10)) + " am";
				}
				else {
					return false;
				}
			}
		}
		else if (tl>=3) {

			var arr = t.split(":");
			if (t.indexOf(":") > 0)
			{
				hr=parseInt(arr[0],10);
				mn=parseInt(arr[1],10);

				if (t.indexOf("pm")>0) {
					mode="pm";
				}
				else {
					mode="am";
				}

				if (isNaN(hr)) {
					hr=0;
				} else {
					if (hr>24) {
						return false;
					}
					else if (hr==24) {
						mode="am";
						hr=0;
					}
					else if (hr>12) {
						mode="pm";
						hr-=12;
					}
				}
			
				if (isNaN(mn)) {
					mn=0;
				}
				else {
					if (mn>60) {
						mn=mn%60;
						hr+=1;
					}
				}
			} else {

				hr=parseInt(arr[0],10);

				if (isNaN(hr)) {
					hr=0;
				} else {
					if (hr>24) {
						return false;
					}
					else if (hr==24) {
						mode="am";
						hr=0;
					}
					else if (hr>12) {
						mode="pm";
						hr-=12;
					}
				}

				mn = 0;
			}
			
			if (hr==24) {
				hr=0;
				mode="am";
			}
			ctl.value=hr+":"+padZero(mn)+" "+mode;
		}
	}

</SCRIPT>

    <link href="../VNPTStyle.css" rel="stylesheet" type="text/css" />
    <link href="../VNPTStyle.css" rel="stylesheet" type="text/css" />
    <link href="../VNPTStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table cellpadding="0" cellspacing="0" width="900">
            <tr>
                <td colspan="1">
                    <uc1:header ID="Header1" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="1">
                    <hmwebmenu:MyMenu ID="MenuTop" runat="server" MenuToLoad="TopMenu" />
                </td>
            </tr>
            <tr>
                <td colspan="1" style="height: 30px" valign="top">
                    <asp:Label ID="Label5" runat="server" Font-Bold="True"
                        Text="Chức năng => Nhập số liệu tiêu thụ xăng dầu" Width="290px"></asp:Label></td>
            </tr>
            <tr>
                <td align="center" colspan="1" rowspan="4" valign="top" style="height: 380px">
                    <table>
                        <tr>
                            <td colspan="5">
                                <asp:Label ID="Label4" runat="server" Font-Bold="True" CssClass="HeaderTitles">Tình hình tiêu thụ xăng dầu</asp:Label></td>
                        </tr>
                        <tr>
                            <td align="center" colspan="5">
                    <asp:Label ID="Label8" runat="server" Text="Chọn trạm báo cáo:"></asp:Label><asp:DropDownList ID="ddlTram" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlTram_SelectedIndexChanged">
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td align="right">
                    <asp:Label ID="Label9" runat="server" Text="Loại máy nổ:"></asp:Label></td>
                            <td align="left"><asp:DropDownList ID="ddlGenerator" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlGenerator_SelectedIndexChanged">
                            </asp:DropDownList></td>
                            <td>
                                <asp:Label ID="Label1" runat="server" Width="40px"></asp:Label></td>
                            <td align="right">
                                <asp:Label ID="Label10" runat="server" Text="Định mức:"></asp:Label></td>
                            <td align="left">
                                <asp:TextBox ID="tbNorms" runat="server" CssClass="TextBox" ReadOnly="True"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:Label ID="Label11" runat="server" Text="Từ giờ:"></asp:Label></td>
                            <td align="left">
                                <asp:TextBox ID="tbFromTime" runat="server" CssClass="TextBoxNumeric" MaxLength="6"
                                    onblur="validateDatePicker(this)">0</asp:TextBox><IMG SRC="../Image/timepicker.gif" BORDER="0" ALT="Pick a Time!" ONCLICK="selectTime(this,tbFromTime)" STYLE="cursor:hand"></td>
                            <td>
                            </td>
                            <td align="right">
                                <asp:Label ID="Label2" runat="server" Text="Đến giờ:"></asp:Label></td>
                            <td align="left">
                                <asp:TextBox ID="tbToTime" runat="server" CssClass="TextBoxNumeric" MaxLength="6"
                                    onblur="validateDatePicker(this)">0</asp:TextBox><IMG SRC="../Image/timepicker.gif" BORDER="0" ALT="Pick a Time!" ONCLICK="selectTime(this,tbToTime)" STYLE="cursor:hand"></td>
                        </tr>
                        <tr>
                            <td align="left">
                    <asp:Label ID="Label12" runat="server" Text="Tiêu tốn Xăng (lít):"></asp:Label></td>
                            <td align="left">
                    <asp:TextBox ID="tbGas" runat="server" CssClass="TextBoxNumeric" MaxLength="6">0</asp:TextBox><asp:RangeValidator
                        ID="RangeValidator1" runat="server" ControlToValidate="tbGas" ErrorMessage="*"
                        Type="Double">*</asp:RangeValidator></td>
                            <td style="width: 3px">
                            </td>
                            <td align="right">
                    <asp:Label ID="Label13" runat="server" Text="Tiêu tốn Dầu (lít):"></asp:Label></td>
                            <td align="left">
                    <asp:TextBox ID="tbOil" runat="server" CssClass="TextBoxNumeric" MaxLength="6">0</asp:TextBox>
                                <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="tbOil"
                                    ErrorMessage="*" Type="Double">*</asp:RangeValidator></td>
                        </tr>
                        <tr>
                            <td style="height: 50px" align="center" colspan="5" rowspan="2">
                    <asp:Button ID="Button1" runat="server" Text="Gửi báo cáo" CssClass="Button" OnClick="Button1_Click" />
                                &nbsp; &nbsp;&nbsp;
                                <asp:Button ID="Button2" runat="server" Text="Sửa báo cáo" CssClass="Button" OnClick="Button2_Click" />
                                &nbsp;&nbsp;
                    <input id="Reset1" type="reset" value="Hủy bỏ" class="Button" /></td>
                        </tr>
                        <tr>
                        </tr>
                        <tr>
                            <td colspan="5">
                            </td>
                        </tr>
                    </table>
                    <asp:GridView ID="gvTTXD" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
                        CellPadding="3" OnPageIndexChanging="gvTTXD_PageIndexChanging" OnRowEditing="gvTTXD_Edit">
                        <FooterStyle BackColor="White" ForeColor="#000066" />
                        <Columns>
                            <asp:CommandField EditText="Sửa" ShowEditButton="True" />
                            <asp:BoundField DataField="StationName" HeaderText="Trạm b&#225;o c&#225;o" SortExpression="StationName" />
                            <asp:BoundField DataField="GeneratorName" HeaderText="Loại m&#225;y nổ" SortExpression="GeneratorName" />
                            <asp:BoundField DataField="Norms" HeaderText="Định mức" SortExpression="Norms" />
                            <asp:BoundField DataField="FromTime" HeaderText="Từ giờ" />
                            <asp:BoundField DataField="ToTime" HeaderText="Tới giờ" />
                            <asp:BoundField DataField="TimeMayNo" HeaderText="Giờ chạy m&#225;y nổ" SortExpression="TimeMayNo" />
                            <asp:BoundField DataField="Gas" HeaderText="Ti&#234;u thụ xăng(l&#237;t)" SortExpression="Gas" />
                            <asp:BoundField DataField="Oil" HeaderText="Ti&#234;u thụ dầu(l&#237;t)" SortExpression="Oil" />
                        </Columns>
                        <RowStyle ForeColor="#000066" />
                        <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
                        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
            </tr>
            <tr>
            </tr>
            <tr>
            </tr>
            <tr>
                <td colspan="1" style="height: 22px">
                    <uc2:footer ID="Footer1" runat="server" />
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>
